﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VISS.API.Users;
using NCT.Framework;

namespace VISS.Web.BackEnd.Modules.User {
    public partial class UserGeneralPage : System.Web.UI.Page {

        //Basic Report 
        protected long User;
        protected long FemaleUser;
        protected long MaleUser;
        protected long ActivedUser;

        //Age Report
        protected long Under20;
        protected long From20To25;
        protected long From26To30;
        protected long From31To35;
        protected long Above35;

        //Last Login Report
        protected long In30Day;
        protected long In7Day;
        protected long In1Day;

        //Message Report
        protected long ToTalMessage;

        protected void Page_Load(object sender, EventArgs e) {
            IUserAdmin _objectUserAdmin = StructureMapFactory.GetInstance<IUserAdmin>();
            IUserGeneralProfileAdmin _objectGeneralAdmin = StructureMapFactory.GetInstance<IUserGeneralProfileAdmin>();

            User = _objectUserAdmin.CountUser();
            ActivedUser = _objectUserAdmin.CountActivedUser();
            FemaleUser = _objectGeneralAdmin.CountFemaleUser();
            MaleUser = _objectGeneralAdmin.CountMaleUser();

            Under20 = _objectGeneralAdmin.CountByAgeRange(0, 20);
            From20To25 = _objectGeneralAdmin.CountByAgeRange(21, 25);
            From26To30 = _objectGeneralAdmin.CountByAgeRange(26, 30);
            From31To35 = _objectGeneralAdmin.CountByAgeRange(31, 35);
            Above35 = _objectGeneralAdmin.CountByAgeRange(36, 100);

            DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);

            In30Day = _objectUserAdmin.CountByLastLogin(startTime.AddDays(-30));
            In7Day = _objectUserAdmin.CountByLastLogin(startTime.AddDays(-7));
            In1Day = _objectUserAdmin.CountByLastLogin(startTime.AddDays(-1));

            ToTalMessage = StructureMapFactory.GetInstance<IUserMessageAdmin>().CountAll();
        }
    }
}
